package com.yuanzong.wuliu.controller.admin.base;

import com.yuanzong.wuliu.common.vo.ApiResult;
import com.yuanzong.wuliu.service.admin.base.AdminFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Api(tags = "管理端 - 文件")
@RequestMapping("/admin/base/file")
@Slf4j
public class AdminFileController {

    @Autowired
    private AdminFileService adminFileService;

//    @ApiOperation("上传文件")
//    @RequestMapping(value = "/upload", method = {RequestMethod.POST})
//    public ApiResult upload(@RequestParam(value = "file", required = false) MultipartFile file) throws Exception {
//        ApiResult result = adminFileService.upload(file);
//        return result;
//    }

    @ApiOperation("上传本地文件")
    @RequestMapping(value = "/localUpload", method = {RequestMethod.POST})
    public ApiResult localUpload(@RequestParam(value = "file", required = false) MultipartFile file) throws Exception {
        ApiResult result = adminFileService.uploadLocal(file);
        return result;
    }

}
